package com.nut.lmsc.api.merchant;

import com.nut.lmsc.common.Holder;
import com.nut.lmsc.common.Result;
import com.nut.lmsc.entity.Shop;
import com.nut.lmsc.service.ShopService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/merchant/shop")
public class ShopController {

    @Autowired
    private ShopService shopService;

    @GetMapping(value = "/my")
    public Result<Shop> my() {
        Integer shopId = Holder.MERCHANT_JWT_THREAD_LOCAL.get().getShopId();
        return shopService.getById(shopId);
    }

    @PutMapping
    public Result update(@RequestBody Shop shop) {
        Integer shopId = Holder.MERCHANT_JWT_THREAD_LOCAL.get().getShopId();
        shop.setId(shopId);
        return shopService.updateById(shop);
    }

}